package com.lu.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.lu.entity.User;
import com.lu.service.UserService;
import com.lu.utils.JSONUtils;
import com.opensymphony.xwork2.ActionSupport;

public class UserListAction extends ActionSupport{
	
	UserService userService = new UserService();
	
	private Integer curr;
	private Integer page;
	private Integer limit;
	private List<User> userList;
	private String code ;
	private Integer count;

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	public String execute() throws Exception{
		System.out.println(curr+"="+page+"="+limit);
		Map<String,Object> map = new HashMap<>();
		map.put("page",page.toString());
		map.put("limit",limit.toString());
		List<User> list = userService.getUserList(map);
		List<User> countList = userService.getUserList(null);
		count = countList.size();
		code="0";
		System.out.println(list.toString());
		JSONUtils json = new JSONUtils();
		String jsonList = json.beanToJson(list);
		userList = list;
		//System.out.println("userList"+userList);
		return "success";
	}

	
	public Integer getCurr() {
		return curr;
	}


	public void setCurr(Integer curr) {
		this.curr = curr;
	}


	public Integer getPage() {
		return page;
	}


	public void setPage(Integer page) {
		this.page = page;
	}


	public Integer getLimit() {
		return limit;
	}


	public void setLimit(Integer limit) {
		this.limit = limit;
	}


	public List<User> getUserList() {
		return userList;
	}

	public void setUserList(List<User> userList) {
		this.userList = userList;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}


	public Integer getCount() {
		return count;
	}


	public void setCount(Integer count) {
		this.count = count;
	}

}
